;;; lambda-tube (?-tube) - A youtube search API and application in scheme.
;;; Copyright (C) 2008 Abhishek Mishra
;;;
;;; This program is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation, either version 3 of the License, or
;;; (at your option) any later version.

;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.

;;; You should have received a copy of the GNU General Public License
;;; along with this program. If not, see <http://www.gnu.org/licenses/>.

; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "lambda-tube"
!define PRODUCT_VERSION "0.4b"
!define PRODUCT_PUBLISHER "Abhishek Mishra"
!define PRODUCT_WEB_SITE "http://code.google.com/p/lambda-tube/"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\lambda-tube.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "lambda-tube\gpl.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\lambda-tube.exe"
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "${PRODUCT_NAME}-${PRODUCT_VERSION}-${CURRENT_DIST_NAME}-installer.exe"
InstallDir "$PROGRAMFILES\lambda-tube"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show

Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "lambda-tube\lambda-tube.exe"
CreateDirectory "$SMPROGRAMS\lambda-tube"
CreateShortCut "$SMPROGRAMS\lambda-tube\lambda-tube.lnk" "$INSTDIR\lambda-tube.exe"
CreateShortCut "$DESKTOP\lambda-tube.lnk" "$INSTDIR\lambda-tube.exe"
SetOverwrite try
File "lambda-tube\build.bat"
File "lambda-tube\build.sh"
File "lambda-tube\gpl.txt"
SetOutPath "$INSTDIR\lib"
File "lambda-tube\lib\iconv.dll"
File "lambda-tube\lib\libmred3m372_000.dll"
File "lambda-tube\lib\libmzsch3m372_000.dll"
File "lambda-tube\lib\UnicoWS.dll"
SetOutPath "$INSTDIR"
File "lambda-tube\MrEd-License.txt"
SetOutPath "$INSTDIR\src"
File "lambda-tube\src\lt-about-dialog.scm"
File "lambda-tube\src\lt-app-details.scm"
File "lambda-tube\src\lt-i18n.scm"
File "lambda-tube\src\lt-if.scm"
File "lambda-tube\src\lt-pref-dialog.scm"
File "lambda-tube\src\lt-preferences.scm"
File "lambda-tube\src\lt-scheduler.scm"
File "lambda-tube\src\lt-search-history.scm"
File "lambda-tube\src\lt-search-main-window.scm"
File "lambda-tube\src\lt-search.scm"
File "lambda-tube\src\lt-tasks.scm"
SetOutPath "$INSTDIR\i18n"
File "lambda-tube\i18n\languages"
File "lambda-tube\i18n\en_US"
File "lambda-tube\i18n\hi_IN"

SectionEnd

Section -AdditionalIcons
SetOutPath $INSTDIR
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS\lambda-tube\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\lambda-tube\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\lambda-tube.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\lambda-tube.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd


Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd

Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd

Section Uninstall
Delete "$INSTDIR\${PRODUCT_NAME}.url"
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\src\lt-tasks.scm"
Delete "$INSTDIR\src\lt-search.scm"
Delete "$INSTDIR\src\lt-search-main-window.scm"
Delete "$INSTDIR\src\lt-search-history.scm"
Delete "$INSTDIR\src\lt-scheduler.scm"
Delete "$INSTDIR\src\lt-preferences.scm"
Delete "$INSTDIR\src\lt-pref-dialog.scm"
Delete "$INSTDIR\src\lt-if.scm"
Delete "$INSTDIR\src\lt-i18n.scm"
Delete "$INSTDIR\src\lt-app-details.scm"
Delete "$INSTDIR\src\lt-about-dialog.scm"
Delete "$INSTDIR\MrEd-License.txt"
Delete "$INSTDIR\lib\UnicoWS.dll"
Delete "$INSTDIR\lib\libmzsch3m372_000.dll"
Delete "$INSTDIR\lib\libmred3m372_000.dll"
Delete "$INSTDIR\lib\iconv.dll"
Delete "$INSTDIR\lambda-tube.exe"
Delete "$INSTDIR\gpl.txt"
Delete "$INSTDIR\build.sh"
Delete "$INSTDIR\build.bat"
Delete "$INSTDIR\i18n\languages"
Delete "$INSTDIR\i18n\hi_IN"
Delete "$INSTDIR\i18n\en_US"

Delete "$SMPROGRAMS\lambda-tube\Uninstall.lnk"
Delete "$SMPROGRAMS\lambda-tube\Website.lnk"
Delete "$DESKTOP\lambda-tube.lnk"
Delete "$SMPROGRAMS\lambda-tube\lambda-tube.lnk"

RMDir "$SMPROGRAMS\lambda-tube"
RMDir "$INSTDIR\i18n"
RMDir "$INSTDIR\src"
RMDir "$INSTDIR\lib"
RMDir "$INSTDIR"

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd


